package com.datang.pet.common.exception;


import com.datang.pet.common.response.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-05-09 19:55
 * @notify controller层统一异常处理
 * @version 1.0
 */

public class GlobalExceptionHandler {
    //异常写入日志
    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class);
    /*
     * @author 顶风少年
     * @date 2019/5/9 23:24
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @param code 状态码
     * @param message 返回说明
     * @param data 返回数据
     * @result
     * @notify
     * version 1.0
     */
    @ExceptionHandler(Exception.class)
    Result handleException(Exception e){
        log.error(e.getMessage(),e);
        return Result.err(e.getMessage());
    }
}
